#ifndef MYGRAPHICSVIEW_H
#define MYGRAPHICSVIEW_H


#include <QPointF>
#include <QMouseEvent>
#include <QGraphicsPolygonItem>
#include <QGraphicsView>

#include "roi.h"

class MyGraphicsView : public QGraphicsView
{
    Q_OBJECT
public:
    explicit MyGraphicsView(QWidget *parent = nullptr);

    void setDraw(bool);
    bool getDraw();
    QGraphicsPolygonItem* getPolygonItem();
    void setmask(Mat* mask);

protected:
    void mousePressEvent(QMouseEvent* event) override;
    void mouseDoubleClickEvent(QMouseEvent* event) override;
    void wheelEvent(QWheelEvent* event) override;
    void Translate(QPointF& delta);
signals:
    void updateROI();

private:
    QGraphicsPolygonItem* m_polygonItem = nullptr;  // 多边形场景对象
    bool m_isDrawing = false;                       // 是否要画多边形
    int m_symbol = 1;                               // 用于减少鼠标缩放误差
    int m_angle = 0;                                // 用于规定缩放范围
    Mat* m_mask = nullptr;                          // 不同场景下对应的掩码
};

#endif // MYGRAPHICSVIEW_H
